﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TimeTravel.Components;
using TimeTravel.Extentions;
using TimeTravel.IData;
using TimeTravel.DataProvider;
using TimeTravel.IServices;

namespace TimeTravel.Services
{
    public class SysLogService:ISysLogService
    {
        private static readonly ISysLogData DataProvider = DataAccess.CreateDataInstance<ISysLogData>();

        #region Implementation of IServiceBase<SysLogInfo>

        /// <summary>
        /// 添加记录（未实现）
        /// </summary>
        [Obsolete("该方法未实现")]
        public int Add(SysLogInfo sysLog)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 删除记录（未实现）
        /// </summary>
        /// <param name="id"></param>
        [Obsolete("该方法未实现")]
        public void Delete(int id)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 更新记录（未实现）
        /// </summary>
        /// <param name="sysLog"></param>
        [Obsolete("该方法未实现")]
        public void Update(SysLogInfo sysLog)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 获取所有
        /// </summary>
        /// <returns></returns>
        public IList<SysLogInfo> GetAll()
        {
            return DataProvider.GetAll();
        }

        /// <summary>
        /// 根据条件获取
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public RecordSet<SysLogInfo> GetBySearch(PageQueryInfo query)
        {
            if (query==null)
            {
                return new RecordSet<SysLogInfo>();
            }
            return DataProvider.GetBySearch(query);
        }

        /// <summary>
        /// 获取详细信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public SysLogInfo GetOne(int id)
        {
            if (id==0)
            {
                return null;
            }
            return DataProvider.GetOne(id);
        }

        /// <summary>
        /// 获取总数
        /// </summary>
        /// <returns></returns>
        public int GetTotalCount()
        {
            return DataProvider.GetTotalCount();
        }

        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="start">开始时间（时间戳格式）</param>
        /// <param name="end">结束时间（时间戳格式）</param>
        public void DeleteBatch(int start, int end)
        {
            if (start<end)
            {
                DataProvider.DeleteBatch(start,end);
            }
        }

        #endregion
    }
}
